package com.xn.app.muying.bean;

import android.text.TextUtils;

import com.jumper.chart.detail.FetalRecords;

/**
 * Created by Terry on 2016/7/28.
 * 胎动 数据类<br>
 * 在图表的里，FetalRecords 的实现者，需实现两个方法，分别返回，每次胎动的<br>
 * 分钟和 秒种<br>
 */
public class FetalMovementInfo implements FetalRecords {


    public String time;


    public FetalMovementInfo(String time){
        this.time = time;
    }

    @Override
    public int getMinutes() {
        return getNumber(true);
    }

    @Override
    public int getSeconds() {
        return getNumber(false);
    }

    private int getNumber(boolean left ){
        if(TextUtils.isEmpty(time)) return 0;
        int index = time.indexOf(":");
        if(index == -1)return 0;
        try {
            if(left)
                return Integer.parseInt(time.substring(0,index));
            else
                return Integer.parseInt(time.substring(index+1));
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
        return 0;
    }
}
